---- Purpose: Xoa phieu nhap kho tu mua hang va hang ban tra lai.
DROP PROCEDURE [dbo].[pr0218]
GO
CREATE  PROCEDURE [dbo].[pr0218] 	@VoucherID varchar(20), 
					@BatchID varchar(20), 
					@DivisionID varchar(20), 
					@TranMonth as int, 
					@TranYear as int
As

-------- Xoa bang Detail ----------
Delete tb0105 
From tb0105 inner join tb0104 on tb0105.VoucherID = tb0104.VoucherID
Where 	tb0105.VoucherID =@VoucherID and
	(tb0104.TableID ='tb0191' or tb0104.TableID ='tb0104') and
	tb0104.BatchID = @BatchID
-------- Xoa bang Master  ----------

Delete tb0104 
Where 	tb0104.VoucherID =@VoucherID and
	(tb0104.TableID ='tb0191' or tb0104.TableID ='tb0104') and
	tb0104.BatchID = @BatchID

Update tb0191 set IsStock =0
	Where 	VoucherID =@VoucherID and
		(TableID ='tb0191' or TableID ='tb0104') and
		BatchID = @BatchID


GO